home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / jvw10.zip / jvwinstl.cmd < prev    next >
OS/2 REXX Batch file  |  1996-05-23  |  13KB  |  385 lines

  1. /* JView Installation REXX script */
  2. /* Copyright (c) 1995  - 1996 Crunch Products                              */
  3.  
  4. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  5. Call SysLoadFuncs
  6. currentdirectory = DIRECTORY()
  7. If Substr( currentdirectory, Length(currentdirectory), 1 ) <> "\"
  8.     Then currentdirectory = currentdirectory || "\"
  9. Call SysCls
  10. Call SysCurState 'ON'
  11. /*Screen is cleared, get destination drive and directory */
  12. Say
  13. Say
  14. Say "Welcome to the JView and JView Pro installation procedure."
  15. Say "If you wish to abandon this installation, hit Ctrl+C to abort. "
  16.  
  17. GetInstallDirectory:
  18. Say
  19. Say "Please enter the complete path where you want JView to be installed."
  20. Say "If you would like it installed in C:\JVW just hit the Enter key"
  21. Say
  22.  
  23. Parse Pull dest_directory
  24.  
  25. /* Use our default if enter key hit */
  26. If dest_directory = ""  Then dest_directory = "C:\JVW\"
  27.  
  28. /* Make sure there is a trailing backslash */
  29. If Substr(dest_directory, Length(dest_directory), 1 ) <> "\"  Then dest_directory = dest_directory || "\"
  30.  
  31. /* Check to make sure a drive is specified - use C drive if not */
  32. installdrive = Filespec("DRIVE", dest_directory)
  33. If installdrive = ""  Then installdrive = "C"
  34.  
  35. /* Check to make sure a path is specified - use root if not */
  36. installpath  = Filespec("PATH", dest_directory) 
  37. If installpath = ""   Then installpath= "\"
  38.  
  39. dest_directory = installdrive || installpath
  40.  
  41. /* uppercase version */
  42. dest_directory_uppercase = Translate(dest_directory)
  43.  
  44. /* And a version without a slash */
  45. dest_noslash = Substr(dest_directory, 1, Length(dest_directory) - 1 )
  46.  
  47. /* Confirm destination directory */
  48. Say
  49. Say "Your specified install location is " dest_directory || "."
  50. Say "Is this correct? (Yes/No):"
  51. Say
  52. Call YesNo
  53. If RESULT <> 'Y' Then Call GetInstallDirectory
  54.  
  55. Say
  56. Say "Creating your specified install directory " dest_directory || " (wait ...)"
  57. rc = SysMkDir(Substr(dest_directory, 1, Length(dest_directory)-1))
  58. Select
  59.      When rc = 0 Then NOP
  60.      When rc = 5 Then Do
  61.            Say "Directory" dest_directory "already exists."
  62.            Say "Enter 'Yes' to continue or 'No' to stop the installation."
  63.            Call YesNo
  64.            If RESULT <> 'Y' Then Exit
  65.            End /* do */
  66.      Otherwise Do
  67.            SAY "Couldn't create destination directory" dest_directory "try another or hit Ctrl+C to stop."
  68.            Call GetInstallDirectory
  69.            End /* do */
  70.      End /* select */
  71.  
  72. /* Install files */
  73.  
  74. Say "UnArchiving files to " dest_directory "..."
  75. Say "JView is packaged using Info-ZIP's compression"
  76. Say "utility.  The installation program uses UnZip to read the zip files."
  77. Say "Info-ZIP's software (Zip, UnZip and related utilities) is"
  78. Say "free and can be obtained as source code or executables from"
  79. Say "various anonymous-ftp sites, including ftp.uu.net:/pub/archiving/zip."
  80. Say
  81. '@unzip -U -j -o jvw_all.zip -d 'dest_directory
  82.  
  83. Say "Doing the JView Folder Creation..."
  84. rc = SysCreateObject("WPFolder", "JView Graphics", "<WP_DESKTOP>", "OBJECTID=<JVIEW_FOLDER>;ICONFILE=", "R")
  85.  
  86. title = 'JView'
  87. classname = 'WPProgram'
  88. location = '<JVIEW_FOLDER>'
  89. filter= '*.GIF,*.JPG,*.JPEG,*.BMP,*.TGA,*.PBM,*.PGM,*.PPM,*.TIF,*.TIFF,*.RLE,*.MET,*.PCX,*.X11,*.RAS,*.SLS,*.PCD,*.PNG;'
  90. setup = 'EXENAME='dest_directory'JView.exe;STARTUPDIR='dest_directory';PROGTYPE=PM;ASSOCFILTER='filter
  91. option = 'update'
  92.  
  93. Say "Doing the JView Object Creation..."
  94. rc = SysCreateObject(classname, title, location, setup, option)
  95. Say
  96. Say "All better now"
  97. Say "You should take the *.BMP association off of the icon editor, if"
  98. Say "you have not done so already."
  99. Say
  100.  
  101. bootdrive = Substr(Translate(Value('PATH',,'OS2ENVIRONMENT')),Pos('\OS2\SYSTEM',Translate(Value('PATH',,'OS2ENVIRONMENT')))-2,2)
  102.  
  103. temp_defined = 0
  104. Call IsTempPathDefined
  105. If RESULT == 'Y' Then temp_defined = 1
  106.  
  107. path_defined = 0
  108. Call IsPathDefined
  109. If RESULT == 'Y' Then path_defined = 1
  110.  
  111. libpath_defined = 0
  112. Call IsLibPathDefined
  113. If RESULT == 'Y' Then libpath_defined = 1
  114.  
  115. If (path_defined = 1 & libpath_defined = 1 & temp_defined = 1)  Then Do
  116.    Say
  117.    Say "Installation Complete"
  118.    Exit
  119.    End  /* Do */
  120.  
  121. Say
  122. Say "Your CONFIG.SYS file defines several environment variables that determine"
  123. Say "how OS/2 and your applications work.  With your permission, this script"
  124. Say "will modify them if needed.  If you choose to allow the modifications"
  125. Say "and they are needed, a backup of your config.sys will be created"
  126. Say "called config.jvw"
  127. Say
  128. If (path_defined = 0 | libpath_defined = 0) Then Do
  129.    Say " First, we will need to add " dest_directory " to your"
  130.    Say " PATH statement and LIBPATH statements.  Doing so will"
  131.    Say " allow you to start JView from any command"
  132.    Say " line.  If " dest_directory " is NOT"
  133.    Say " placed into these variables, you can still run"
  134.    Say " JView from its Icon or from the " dest_directory 
  135.    Say " directory via the command line."
  136.    Say
  137.    Say "Do you wish to modify your config.sys? (Yes/No)"
  138.    Say
  139.    Call YesNo
  140.    If RESULT <> 'Y' Then Do
  141.       Say 
  142.       Say "Not updating config.sys, Installation Complete."
  143.       Exit
  144.       End  /* Do */
  145.    End /* do */
  146.  
  147. If (temp_defined = 0) Then Do
  148.     Call CreateTemp
  149.     temp_directory = RESULT
  150.     If temp_directory = "" Then temp_defined = 1
  151.     End  /* Do */
  152.  
  153. If (path_defined = 0 | libpath_defined = 0) Then Call UpdateConfigPaths
  154. /*Wont get here unless paths were OK to start with */
  155. If temp_defined = 0 Then Do
  156.    oldconfig=bootdrive'\CONFIG.SYS'
  157.    rc = lineout(oldconfig, "SET TMP="||temp_directory)
  158.    rc = lineout(oldconfig)
  159.    Say "Installation done.  Reboot your machine for TMP"
  160.    Say "directory to become useful."
  161.    Exit
  162. End  /* Do */
  163.  
  164. Say
  165. Say "Installation Complete."
  166. Say "You will need to reboot your computer for changes to take effect."
  167. Say
  168. Exit
  169.    
  170. UpdateConfigPaths:
  171. oldconfig=bootdrive'\CONFIG.SYS'
  172. newconfig=bootdrive'\CONFIG.JVW'
  173. tmpconfig=bootdrive'\TMP.SYS'
  174. Call SysFileDelete(newconfig)
  175.  
  176. Do while lines(oldconfig)
  177.     inline=linein(oldconfig)
  178.     upperinline = Translate(inline)
  179.     Parse Value inline With os2var '=' os2value
  180.     os2var = Translate(os2var)
  181.     If ( (os2var =  "SET PATH" & path_defined = 0) | (os2var = "LIBPATH" & libpath_defined = 0) ) Then Do
  182.         /*
  183.          * see if there is a ; at the end of the value
  184.         */
  185.         position=lastpos(';',os2value)
  186.         lenvalue=length(os2value)
  187.  
  188.         If position=lenvalue Then Do
  189.            /* ; at end of value */
  190.            jview_line = os2var'='os2value''dest_noslash';'
  191.            End
  192.         Else Do
  193.            /* ; NOT at end of value */
  194.            jview_line=os2var'='os2value';'dest_noslash';'
  195.            End
  196.         rc = lineout(newconfig, jview_line)
  197.         End
  198.     Else
  199.         rc = lineout(newconfig, inline)
  200.     End
  201.  
  202. If temp_defined = 0 Then rc = lineout(newconfig, "SET TMP="||temp_directory)
  203.  
  204. rc = lineout(newconfig)
  205. rc = lineout(oldconfig)
  206.  
  207. /******************************************************************/
  208. /* Copy created file(CONFIG.JVW) to temporary file(TMP.SYS),      */
  209. /* copy original file(CONFIG.SYS) to new file(CONFIG.JVW),        */
  210. /* and copy temporary file(TMP.SYS) to original file(CONFIG.SYS). */
  211. /******************************************************************/
  212.  
  213. '@copy 'oldconfig' 'tmpconfig' 2>nul >nul'
  214. '@copy 'newconfig' 'oldconfig' 2>nul >nul'
  215. '@copy 'tmpconfig' 'newconfig' 2>nul >nul'
  216.  
  217. Call SysFileDelete( tmpconfig )
  218.  
  219. SAY "  Your CONFIG.SYS file has been updated."
  220. SAY "  Your old CONFIG.SYS has been copied to " newconfig || "."
  221. SAY "  in order for the changes to take effect,"
  222. SAY "  please Shutdown and Restart OS/2."
  223.  
  224. Exit
  225.  
  226. IsLibPathDefined:
  227. oldconfig=bootdrive'\CONFIG.SYS'
  228. Do while lines(oldconfig)
  229.     inline=linein(oldconfig)
  230.     upperinline = Translate(inline)
  231.     Parse Value inline With os2var '=' os2value
  232.     os2var = Translate(os2var)
  233.     If (os2var = "LIBPATH") Then Do
  234.        os2value = Translate(os2value)
  235.        If Pos(Translate(Substr(dest_directory, 1, Length(dest_directory) - 1 )), os2value) <> 0 Then Do
  236.